﻿@using PagedList
@using PagedList.Mvc
@using StudyEnglish.Application.Filter
@model IPagedList<StudyEnglish.Model.File>
<h2>
    Files library</h2>
<div class="row">
    <div class="span3">
        @{
            var smartFilter = (SmartFilter<StudyEnglish.Model.File>)ViewBag.Filter;
            //smartFilter.InitialUrl = Url.Action("Index", new {page = Model.PageNumber});
            Html.RenderPartial("FilterRenderer", smartFilter);
        }
    </div>
    <div class="span9">
        <div class="row" style="text-align: right">
            
                <form class="form-search">
                <input type="text" class="input-medium">
                <button type="submit" class="btn">
                    Search</button>
                </form>
            
        </div>
        <div class="row">
            <table cellpadding="0" cellspacing="0" border="0" class="table table-striped" id="filesTable" width="100%">
                <tbody>
                    @foreach (var file in Model)
                    {
                        <text>
                        <tr id="@file.Id" >
                            <td>
                                @{
                                    Html.RenderPartial("FilePreview", file);
                                }
                            </td>
                        </tr>
                        </text>
                    }
                </tbody>
            </table>
        </div>
        <div class="row">
            @Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
        </div>
        <div class="row">
        </div>
    </div>
</div>
@*@using (Html.BeginForm("Update", "Library", FormMethod.Post))
{
    <div class="row">
        <div class="span2">
            @{
                Html.RenderPartial("DictionaryItemSelector", Model.Dictionary.Levels);
            
                Html.RenderPartial("DictionaryItemSelector", Model.Dictionary.Categories);
            
                Html.RenderPartial("DictionaryItemSelector", Model.Dictionary.SubCategories);
            
                Html.RenderPartial("DictionaryItemSelector", Model.Dictionary.Topics);
            
                Html.RenderPartial("DictionaryItemSelector", Model.Dictionary.Types);
            }
        </div>
    
        
    </div>
}*@
<script type="text/javascript">

    $(document).ready(function () {

        var oTableName = $('#filesTable');

        oTableName.$("[jeditable]").editable('../../Library/UpdateFile', {
            "callback": function (sValue, y) {
                var aPos = oTableName.fnGetPosition(this);
                oTableName.fnUpdate(sValue, aPos[0], aPos[1]);
            },
            "submitdata": function (value, settings) {
                return {
                    "row_id": this.parentNode.getAttribute('id'),
                    "column": oTableName.fnGetPosition(this)[2]
                };
            },

            "width": "100%",
            "height": "60px",
            "type": 'textarea',
            "cancel": 'Cancel',
            "submit": 'OK'

        });

    });
</script>
